<!--模板代码-->
<template>
  <div class="home">
    <el-container>
      <!-- 头部区域 -->
      <el-header height="80px">
        <div>
          <img alt="" src="../assets/logo.png">
          <span> 欢迎来到爱奇艺后台管理系统</span>
        </div>
        <el-button type="info" @click="logout">退出</el-button>
      </el-header>


      <el-container>
        <!-- 左侧菜单 -->
        <el-aside width="200px">

          <el-row class="tac">
            <el-col :span="24" align="left">

              <el-menu
                  active-text-color="#409EFF"
                  background-color="#333744"
                  class="el-menu-vertical-demo"
                  default-active="1"
                  text-color="#fff"
                  @close="handleClose"
                  @open="handleOpen"

              >

                <el-menu-item index="/" @click="getData">
                  <i class="el-icon-menu"></i>
                  <span slot="title">首页</span>
                </el-menu-item>
                <el-menu-item index="1">
                  <i class="el-icon-document"></i>
                  <span slot="title">统计数据</span>
                </el-menu-item>

                <el-submenu index="2"
                >
                  <template slot="title">
                    <i class="el-icon-edit"></i>
                    <span>编辑内容</span>
                  </template>
                  <el-menu-item-group>
                    <el-menu-item index="/movieList" @click="getData">编辑电影</el-menu-item>
                    <el-menu-item index="/movieAndActorList" @click="getData">编辑电影演员</el-menu-item>
                    <el-menu-item index="/actorList" @click="getData">编辑演员资料</el-menu-item>
                    <el-menu-item index="/categoryList" @click="getData">编辑电影类型</el-menu-item>
                    <el-menu-item index="/recommendList" @click="getData">编辑电影推荐</el-menu-item>
                  </el-menu-item-group>

                </el-submenu>


                <el-submenu index="3">
                  <template slot="title">
                    <i class="el-icon-setting"></i>
                    <span>首页配置</span>
                  </template>
                  <el-menu-item-group>
                    <el-menu-item index="4-1">配置最新电影</el-menu-item>
                    <el-menu-item index="4-2">配置最热电影</el-menu-item>

                  </el-menu-item-group>

                </el-submenu>


                <el-menu-item index="4">
                  <i class="el-icon-user"></i>
                  <span slot="title" @click="logout">注销</span>
                </el-menu-item>
              </el-menu>

            </el-col>
          </el-row>

        </el-aside>
        <el-main>
          <!-- 功能区域需要显示的内容是由其它组件提供的-->
          <router-view/>
        </el-main>
      </el-container>
    </el-container>

  </div>
</template>

<!--行为-->
<script>

export default {
  name: 'Home',
  methods: {

    handleOpen(key, keyPath) {
      console.log(key, keyPath);
    },
    handleClose(key, keyPath) {
      console.log(key, keyPath);
    },
    getData(e) {
      console.log(e.index);
      this.$router.push(e.index);
    },
    logout() {
      localStorage.removeItem("token")
      this.$router.push("/login")
    }
  }
}
</script>

<!--样式-->
<style scoped>


.el-header {
  background-color: #2b4b6b;
  display: flex;
  justify-content: space-between;
  padding-left: 0;
  align-items: center;
  color: #fff;
  font-size: 20px;

}

.el-header div {
  display: flex;
  align-items: center;
}

.el-header div img {
  margin-left: 5px;
  width: 60px;
  height: 60px;
}

.el-header span {
  font-size: 30px;
  margin-left: 200px;
  color: #fff;
}

.el-aside {
  background-color: #333744;
  color: #333;
  text-align: center;
  line-height: 200px;
  height: 900px;
}

.el-main {
  background-color: #E9EEF3;
  color: #333;
  text-align: center;
  line-height: 160px;
}

body > .el-container {
  margin-bottom: 40px;
}

.el-container:nth-child(5) .el-aside,
.el-container:nth-child(6) .el-aside {
  line-height: 260px;
}

.el-container:nth-child(7) .el-aside {
  line-height: 320px;
}

.el-menu {

}
</style>
